package l.l.w.网易2018实习.牛牛找工作;

import java.util.*;

/**
 * Created by llw on 2018/3/28/0028.
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int N = scanner.nextInt();
        int M = scanner.nextInt();
        int[][] works = new int[N][2];
        int[] Ai = new int[M];
        for(int i = 0; i < N; ++i){
            works[i][0] = scanner.nextInt();
            works[i][1] = scanner.nextInt();
        }
        int[][] res = new int[M][3];
        for(int j = 0; j < M; ++j){
            int[] temp = new int[3];
            temp[0] = scanner.nextInt();
            temp[1] = j;
            temp[2] = 0;
            res[j] = temp;
        }

        new Main().getResult(N,M,works,res);
        for(int i = 0; i < M; ++i){
            System.out.println(res[i][2]);
        }
    }

    private void getResult(int n, int m, int[][] works, int[][] res) {
        Comparator<int[]> com = new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[0] - o2[0];
            }
        };
        Arrays.sort(works, com);
        Arrays.sort(res, com);
        int[] pre = works[0];
        int[] result = new int[m];
        int max = 0;
        int j = 0;
        for(int i = 0; i< m; ++i){
            for(; j < n; ++j){
                if(works[j][0] > res[i][0])break;
                if(works[j][1] > max) max = works[j][1];
            }
            res[i][2] = max;
        }
        Arrays.sort(res, new Comparator<int[]>() {
            @Override
            public int compare(int[] o1, int[] o2) {
                return o1[1] - o2[1];
            }
        });
//        return res;
    }
}
